<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>信息修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-body" style="position: absolute;left:20%;top:20%">
    <form class="layui-form">

        <div class="layui-form-item">
            <label for="managerId" class="layui-form-label" >
                <span class="x-red">*</span>经理编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerId" disabled  name="managerId" th:value="${user.managerId}" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>

            <label for="managerNickName" class="layui-form-label" style="margin-left: 118px">
                <span class="x-red">*</span>登录名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerNickName" name="managerNickName" required="" th:value="${user.managerNickName}" lay-verify="userName"
                       autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <div>
                <label for="managerName" class="layui-form-label">
                    <span class="x-red">*</span>姓名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="managerName" name="managerName" required="" th:value="${user.managerName}" lay-verify="name"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div>
                <label for="managerSex" class="layui-form-label" style="margin-left: 118px">
                    <span class="x-red">*</span>性别
                </label>
                <div class="layui-input-inline" id="userSex" name="userSex"   >
                    <input type="radio" name="managerSex" value="男" title="男" th:if="${user.managerSex} eq '男'"  checked="" >
                    <input type="radio" name="managerSex" value="男" title="男" th:if="${user.managerSex} eq '女'"  >
                    <input type="radio" name="managerSex" value="女" title="女" th:if="${user.managerSex} eq '女'"  checked="" >
                    <input type="radio" name="managerSex" value="女" title="女" th:if="${user.managerSex} eq '男'" >
                </div>
            </div>

        </div>


        <div class="layui-form-item">
            <label for="managerBirth" class="layui-form-label">
                <span class="x-red">*</span>出生日期
            </label>
            <div class="layui-input-inline">
                <input type="date" id="managerBirth" name="managerBirth" required="" th:value="${user.managerBirth}" lay-verify="userBirth"
                       autocomplete="off" class="layui-input">
            </div>


            <label for="managerTel" class="layui-form-label" style="margin-left: 118px">
                <span class="x-red">*</span>电话号码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerTel" name="managerTel" required="" th:value="${user.managerTel}" lay-verify="phone"
                       autocomplete="off" class="layui-input">
            </div>


        </div>



        <div class="layui-form-item">
            <label for="managerEmail" class="layui-form-label">
                <span class="x-red">*</span>邮箱
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerEmail" name="managerEmail" required=""  th:value="${user.managerEmail}" lay-verify="email"
                       autocomplete="off" class="layui-input">
            </div>


            <label for="managerEdu" class="layui-form-label" style="margin-left: 118px">
                <span class="x-red">*</span>学历
            </label>
            <div class="layui-input-inline" >
                <select name="managerEdu" id="managerEdu">
                    <option  th:value="${user.managerEdu}" > <span th:text="${user.managerEdu}"></span></option>
                    <option value="小学">小学</option>
                    <option value="初中">初中</option>
                    <option value="高中">高中</option>
                    <option value="本科">本科</option>
                    <option value="硕士">硕士</option>
                    <option value="博士">博士</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label for="managerIdCard" class="layui-form-label">
                <span class="x-red">*</span>身份证号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerIdCard" name="managerIdCard" required="" th:value="${user.managerIdCard}" lay-verify="userIdCard"
                       autocomplete="off" class="layui-input">
            </div>


            <label for="managerText" class="layui-form-label" style="margin-left: 118px">
                备注
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerText" name="managerText" required="" th:value="${user.managerText}" style="width: auto;min-width: 190px"
                       autocomplete="off" class="layui-input">
            </div>
        </div>




        <div class="layui-form-item" style="margin-top: 30px">
            <label  class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                保存信息
            </button>
        </div>
    </form>
</div>
<script>


    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            userName: function(value){
                if(value.length < 3){
                    return '登录名至少得3个字符';
                }
            }
            ,name: function(value){
                if(value.length < 2){
                    return '姓名名至少得2个字符';
                }
            }
            ,userIdCard: [/^([0-9]){7,18}(x|X)?$ 或 ^\d{8,18}|[0-9x]{8,18}|[0-9X]{8,18}?$$/,'请输入正确身份证号']
            ,userUnit: function(value){
                if(value.length < 2){
                    return '工作单位至少得2个字符';
                }
            }
        });

        //监听提交
        form.on('submit(add)', function(data){
            console.log(data);
            $.ajax({
                url:"/manager/maginfo",
                type:"get",
                data:data.field,
                dataType:"json",//返回的数据类型
                success:function(data){
                    //定义{info:"修改成功"}
                    $("#info").text(data.info);

                    if(data.info=="保存成功"){
                        layer.alert("保存成功",function(index){
                            // 1 关闭弹窗

                            layer.close(index);
                        })

                    }else {
                        if (data.info=="用户重名")
                        {
                            layer.alert("登录名重名",{icon:layui-icon-close},function(index){
                                // 1 关闭弹窗

                                layer.close(index);
                            })
                        }else {
                            if (data.info=="经理不存在")
                            {
                                layer.alert("经理不存在",function(index){
                                    // 1 关闭弹窗

                                    layer.close(index);
                                })
                            }else {
                                layer.alert("保存失败");
                            }
                        }
                    }
                }
            })

            return false;
        });





    });
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>